package com.mhkj.base.itemInfo.item.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.mhkj.base.rbac.role.entity.SystemRole;
import com.mhkj.base.region.entity.TSysNation;
import com.mics.core.common.validate.annotation.NotNull;
import com.mics.core.common.validate.annotation.Unique;
import com.mics.core.common.validate.annotation.Validate;
import com.mics.core.system.base.entity.BaseDomain;

@Entity
@Table(name="t_item")
@Validate
public class Item extends BaseDomain{
	

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 6842956576986889374L;
	
	/**
	 * 项目编号
	 */
	@Unique(message="项目编号不能重复")
	@NotNull(message="项目编号不能为空")
	@Column(name="number",length=48,nullable=false)
	private String number;
	
	/**
	 * 项目名称
	 */
	@NotNull(message="项目名称不能为空")
	@Unique(message="项目名称不能重复")
	@Column(name="name",length=48,nullable=false)
	private String name;
	
	/**
	 * 地块名称
	 */
	@Column(name="earth_name",length=48)
	private String earthName;

	/**
	 * 简称
	 */
	@Unique(message="项目简称不能重复")
	@Column(name="abbreviation",length=48)
	private String abbreviation;
 
	/**
	 *  项目地址
	 */
	
	@NotNull(message="地址不能为空")
	@Column(name="item_address",length=128)
	private String itemAddress;
	
	
	/**
	 *  项目开始日期
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="item_start_date")
	private Date itemStartDate;
	
	/**
	 *  项目结束日期
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="item_end_date")
	private Date itemEndDate;
	
	
	/**
	 *  开工日期
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="work_start_date")
	private Date workStartDate;
	
	/**
	 *  竣工日期
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="work_end_date")
	private Date workEndDate;
	
	
	/**
	 *  开盘日期
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="open_date")
	private Date openDate;
	
	/**
	 *  封盘日期
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="seal_date")
	private Date sealDate;
	/**
	 *  项目负责人
	 */
	@Column(name="functionary_id",length=64)
	private String functionaryId;
	
	/**
	 *  项目负责人名字
	 */
	@Transient
	private String functionaryName;
	
	/**
	 *  所属公司
	 */
	@Column(name="affiliated_company_id",length=64)
	private String affiliatedCompanyId;
	  
	/**
	 *  所属公司名称
	 */
	@Transient
	private String affiliatedCompanyName;
	

	/**
	 *  项目状态(在建:0,暂停:1,搁置:2,结案:3)
	 */
	@Column(name="status")
	private int status=0;

	/**
	 *  项目状态(在建:0,暂停:1,搁置:2,结案:3)
	 */
	@Transient
	private String statusName;
	/**
	 * 目标客户
	 */
	@Column(name="target_client",length=550)
	private String targetClient;
	
	/**
	 * 项目描述
	 */
	@Column(name="item_description",length=550)
	private String itemDescription;
	
	@OneToOne
	@JoinColumn(name = "city_id")
	private TSysNation tSysNation;
	
	/**
	 * 城市id
	 */
	 @Transient
	 private Long cityId;
	/**
	 * 省id
	 */
	@Transient
	private Long provinceId;
	
	@ManyToMany()
	@JoinTable(name = "t_sys_role_item",joinColumns = {@JoinColumn(name = "item_id", referencedColumnName = "id")},
	inverseJoinColumns = {@JoinColumn(name = "sysRole_id", referencedColumnName ="id")})
	private List<SystemRole> systemRoles;

	public Long getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(Long provinceId) {
		this.provinceId = provinceId;
	}

	public Long getCityId() {
		return cityId;
	}

	public void setCityId(Long cityId) {
		this.cityId = cityId;
	}

	public String getStatusName() {
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEarthName() {
		return earthName;
	}

	public void setEarthName(String earthName) {
		this.earthName = earthName;
	}

	public String getAbbreviation() {
		return abbreviation;
	}

	public void setAbbreviation(String abbreviation) {
		this.abbreviation = abbreviation;
	}

	public String getItemAddress() {
		return itemAddress;
	}

	public void setItemAddress(String itemAddress) {
		this.itemAddress = itemAddress;
	}

	public Date getItemStartDate() {
		return itemStartDate;
	}

	public void setItemStartDate(Date itemStartDate) {
		this.itemStartDate = itemStartDate;
	}

	public Date getItemEndDate() {
		return itemEndDate;
	}

	public void setItemEndDate(Date itemEndDate) {
		this.itemEndDate = itemEndDate;
	}

	public Date getWorkStartDate() {
		return workStartDate;
	}

	public void setWorkStartDate(Date workStartDate) {
		this.workStartDate = workStartDate;
	}

	public Date getWorkEndDate() {
		return workEndDate;
	}

	public void setWorkEndDate(Date workEndDate) {
		this.workEndDate = workEndDate;
	}

	public Date getOpenDate() {
		return openDate;
	}

	public void setOpenDate(Date openDate) {
		this.openDate = openDate;
	}

	public Date getSealDate() {
		return sealDate;
	}

	public void setSealDate(Date sealDate) {
		this.sealDate = sealDate;
	}

	public String getFunctionaryId() {
		return functionaryId;
	}

	public void setFunctionaryId(String functionaryId) {
		this.functionaryId = functionaryId;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getTargetClient() {
		return targetClient;
	}

	public void setTargetClient(String targetClient) {
		this.targetClient = targetClient;
	}

	public String getItemDescription() {
		return itemDescription;
	}

	public void setItemDescription(String itemDescription) {
		this.itemDescription = itemDescription;
	}

	public String getAffiliatedCompanyId() {
		return affiliatedCompanyId;
	}

	public void setAffiliatedCompanyId(String affiliatedCompanyId) {
		this.affiliatedCompanyId = affiliatedCompanyId;
	}

	public TSysNation gettSysNation() {
		return tSysNation;
	}

	public void settSysNation(TSysNation tSysNation) {
		this.tSysNation = tSysNation;
	}

	public String getAffiliatedCompanyName() {
		return affiliatedCompanyName;
	}

	public void setAffiliatedCompanyName(String affiliatedCompanyName) {
		this.affiliatedCompanyName = affiliatedCompanyName;
	}

	public String getFunctionaryName() {
		return functionaryName;
	}

	public void setFunctionaryName(String functionaryName) {
		this.functionaryName = functionaryName;
	}
	
	@JsonBackReference
	public List<SystemRole> getSystemRoles() {
		return systemRoles;
	}

	public void setSystemRoles(List<SystemRole> systemRoles) {
		this.systemRoles = systemRoles;
	}
	
	
	 
	
}
